	$(document).ready(function() {
		//将热门搜索的数据展示在页面上
		$.ajax({
			type: "post",
			url: "http://a.91jfk.com/Product/Shopindex/hot_search_data",
			async: true,
			data: {},
			dataType: 'json',
			success: function(res) {
				console.log(res);
				if(res.code == '1') {
					var name;
					var id;
					console.log(res.message.length);
					for(var i = 0; i < res.message.length; i++) {
						name = res.message[i].name;
						id = res.message[i].id;
						showItem_hot(name, id);
					}
				}
			},
			error: function(err) {}
		});
		//将历史搜索的数据展示在页面上
		$.ajax({
			type: "post",
			url: "http://a.91jfk.com/Product/Shopindex/history_search_data",
			async: true,
			data: {},
			dataType: 'json',
			success: function(res) {
				console.log(res);
				if(res.code == '1') {
					var name;
					var id;
					console.log(res.message.length);
					for(var i = 0; i < res.message.length; i++) {
						name = res.message[i].search_name;
						id = res.message[i].id;
						showItem_history(name, id);
					}
				}
			},
			error: function(err) {}
		});
		//创建热门数据标签
		function showItem_hot(name, id) {
			var a = $('<a  class="name">' + name + '</a>');
			var checkItem = $('<div class="check" style="display:none">' + id + '</div>');
			$(".hot_search_list").append(a).append(checkItem);
		}
		
		//给热门搜索添加点击事件，跳转跳到列表详情
		$(".hot_search_list").on("click", ".name", function() {
			var text = $(this).text();
			var storage_hot = window.localStorage;
			storage_hot.setItem("hot_data", text);
			window.location.href = "shop_show.html";
		});

		//创建历史数据的标签
		function showItem_history(name, id) {
			var a = $('<a class="name" >' + name + '</a>');
			var checkItem = $('<div class="check" style="display:none">' + id + '</div>');
			$(".history_search_list").append(a).append(checkItem);
		}

		//点击"搜索"
		$(".search_shop  span").bind("click", function() {
			var keyword = $(this).parent(".search_shop").find("#search").val();
			var storage = window.localStorage;
			storage.setItem("search_data", keyword);
			window.location.href = "shop_show.html";
		});

		//点击删除图片弹框显示
		$('.history_search img').bind("click", function(e) {
			$(".mengban").css("display", "block");
			$(".delete").css("display", "block");
			$(".yes").css("display", "block");
			e.stopPropagation();
			//点击确定按钮，发送ajax请求，进行删除
			$(".yes").bind("click", function(e) {
				e.stopPropagation();
				$.ajax({
					type: "post",
					url: "http://a.91jfk.com/Product/Shopindex/del_history",
					data: {},
					datatype: "json",
					success: function(xhr) {
						if(xhr.code == "1") {
							$(".delete").css("display", "none");
							$(".yes").css("display", "none");
							$(".mengban").css("display", "none");
							setTimeout(function() {
								window.location.href = window.location.href + "?id=" + 10000 * Math.random();
							}, 500);
						} else {
							window.location.reload();
						}
					}
				})

			});
		});
		//点击取消，蒙版消失，弹框消失
		$(".delete p:last-child").bind("click", function() {
			$(".mengban").css("display", "none");
			$(".delete").css("display", "none");
			$(".yes").css("display", "none");

		});

	})